Skip to content

Let the project shape the bit-exact gate's inputs through recast_inputs.py - #31

Open
second5t wants to merge 3 commits into
mainfrom
project-input-profile
Open

Let the project shape the bit-exact gate's inputs through recast_inputs.py#31
second5t wants to merge 3 commits into
mainfrom
project-input-profile

Conversation

@second5t

@second5t second5t commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What this is

The bit-exact gate draws its inputs uniformly, and for a subprogram whose domain is narrower than that (MINPACK's dogleg/r1updt: extents that must be sorted, packed, positive) every draw is either redrawn or compared only after its free extents were moved. The training lab found that no engine change fixes this without lying about the source; the project has to say what its inputs look like.

  • Let the project shape the generated inputs through recast_inputs.py — a recast_inputs.py at the root the run was given, with prepare(unit, subprogram, inputs, rng), receives one trial's draw by argument name and returns it shaped into the source's domain (or None to leave it alone). A shaped draw is an assertion that the reference takes it and is judged as one: never redrawn, a candidate that refuses it has failed, a reference that refuses it means the profile is wrong (InputProfileError). Metrics say how many points were shaped. Tests in tests/test_bitexact_draws.py.
  • Read recast_inputs.py without writing bytecode into the project root — compile + exec instead of import, so no __pycache__ lands in a corpus checkout (the checkout is content-addressed by the run).
  • Let a refused input profile end the run rather than fail the unitaa03480 turns a verifier crash into a unit failure so one plugin bug does not end the walk; that catch also swallowed InputProfileError, which would have recorded a mistake in the corpus checkout as a translation defect and sent a repair agent after the engine. It now escapes through the unit and run aborted events like every other operator error. Test in tests/test_run.py.

The first two commits are the training lab's, cherry-picked onto main (one trivial conflict: PROCEDURE_DTYPE kept as main spells it) and re-signed. Verified there end to end: with a MINPACK profile all 22 subprograms are compared at zero redraws (dogleg/r1updt included); without one the same engine fails those two exactly as before. Not included: the lab's agent-authored repair for fortran-utils sorting (companion modules staged next to the candidate, generic interfaces reaching private specifics) — pending human audit, separate PR if wanted.

Checks run locally (uv, Python 3.11, gfortran 13)

  • ruff check . clean; mypy clean (109 files); tools/check_signoff.py origin/main..HEAD clean.
  • pytest with dev fortran translate verify: 900 passed, 20 skipped.
  • tools/check_hygiene.py .: the same 4 lines as origin/main (docs/roadmap.md, src/recast/fortran/constants.py), nothing from this branch.
  • ruff format --check .: the same 2 Markdown files as origin/main, untouched here.

🤖 Generated with Claude Code

A subprogram whose domain is a relation between its arguments -- a
packed triangular workspace whose extent is n(n+1)/2, a pivot vector that
must be a permutation, a mode that must be 1 or 2 -- cannot be drawn
independently per argument, and the redraw rules only report how often
that failed. The project now says what it accepts: a `recast_inputs.py`
at the source root defines `prepare(unit, subprogram, inputs, rng)`,
which returns one trial's draw shaped into the domain, or None to leave
it to the generated rules. It lives in the source tree, so the report's
identity covers it with nothing new to digest.

A shaped draw is the project asserting the reference takes it, and is
judged that way: the reference runs first, and if it raises or produces
a NaN the verification stops with InputProfileError naming the file,
subprogram and trial -- that is the profile's fault, never the
candidate's, and it is never drawn again. A candidate that raises on a
shaped draw the reference took has failed the translation, no redraw.
A profile that does not import, defines no prepare, edits the draw in
place and returns None, or renames the arguments stops the gate the
same way. Replays never run the profile: recorded inputs are already in
the domain, and letting anything edit them would rewrite the exam.

The candidate-side `_PREPARE_INPUTS` hook is gone; the emitted module
is what is being judged and does not get to choose its own inputs.
Metrics carry `input_profile` and the `shaped` subprograms, and each
subprogram reports how many trials were shaped.

On the MINPACK corpus a 70-line profile takes dogleg and r1updt from
10 of 10 trials reshaped to 165 and 351 bit-exact points at their real
packed extents, with every subprogram at zero redraws.

(cherry picked from commit 28bfc8e13106b12e014929670a62fd13dcc02c5c)

Signed-off-by: 2st <mouseisnotalwaysmouse@outlook.com>
The profile was loaded through a SourceFileLoader, which cached its
bytecode as __pycache__/recast_inputs.cpython-311.pyc beside it. The root
is a checkout whose cleanliness is checked -- the training lab refuses to
onboard a dirty tree, and its prepare-inputs command refused to commit the
profile because the engine's own self-check had littered the worktree.
Compile and run the source by hand into a fresh module namespace instead.

(cherry picked from commit 21367454aa6aa13832782c16e7fc3fc2e6e534c2)

Signed-off-by: 2st <mouseisnotalwaysmouse@outlook.com>
The verifier catch that turns a plugin crash into a unit failure also
swallowed InputProfileError -- the project's recast_inputs.py shaping a
draw the reference refuses. That is the profile's fault, not the unit's:
recorded as a failed verdict it reads as a translation defect and sends a
repair agent after the engine for a mistake in the corpus checkout. The
error now escapes the walk as every other operator error does, through
the unit and run "aborted" events.

Signed-off-by: 2st <mouseisnotalwaysmouse@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant